/*******************************************************************************
 * Copyright (c) 2010, 2030 www.itlaobing.cn
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 *******************************************************************************/
package cn.itlaobing.dao;

import java.sql.SQLException;
import java.util.*;

import cn.itlaobing.model.OrderModel;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

/** 
 * ClassName: OrderDao <br/> 
 * Function: TODO 功能描述 <br/> 
 * date: 2017年11月1日 下午2:06:36 <br/> 
 * 
 * @author lhb 
 * @version  
 * @since JDK 1.8 
 */
public class OrderDao extends BaseDao {
	//支付
	public int zhifu(String count)throws ClassNotFoundException, SQLException{
		QueryRunner qr=new QueryRunner(getDataSource());
		String sql="update tbl_orderform set orderstatus=? where orderformcount=?";
		return qr.update(sql,2,count);
	}
//取消订单
	public int quxiao(String count)throws ClassNotFoundException, SQLException{
		QueryRunner qr=new QueryRunner(getDataSource());
		String sql="update tbl_orderform set orderstatus=? where orderformcount=?";
		return qr.update(sql,1,count);
	}
	//删除订单
	public int del(String count)throws ClassNotFoundException, SQLException{
		QueryRunner qr=new QueryRunner(getDataSource());
		String sql="delete from tbl_orderform where orderformcount=?";
		return qr.update(sql,count);
	}

	//查询
	public List<OrderModel> findAll(int id)throws SQLException{
		String sql="select * from tbl_orderform where userid=?";
		QueryRunner qr=new QueryRunner(getDataSource());
		BeanListHandler<OrderModel> beanListHandler=new BeanListHandler<OrderModel>(OrderModel.class);
		return qr.query(sql,beanListHandler,id);
	}
}
